local zhengshuo = fk.CreateSkill {
  name = "th_zhengshuo",
  max_turn_use_time = 1,
}

zhengshuo:addEffect(fk.Damage, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhengshuo.name) and data.to and data.to ~= player
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function(p) return player:inMyAttackRange(p) end)
    if #targets < 1 then return end
    local to = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#th_zhengshuo-invoke::" .. data.to.id,
      skill_name = zhengshuo.name,
      cancelable = true
    })
    if #to > 0 then
      event:setCostData(self, { tos = to })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local user = event:getCostData(self).tos[1]
    local dat = room:askToUseVirtualCard(user, {
      name = "slash",
      skill_name = zhengshuo.name,
      prompt = "#th_zhengshuo-slash:" .. player.id .. ":" .. target.id,
      cancelable = true,
      extra_data = {
        bypass_distances = true,
        bypass_times = true,
        must_targets = { data.to.id },
      },
      card_filter = {
        n = 1,
        pattern = ".|.|.|hand"
      },
    })
    if not dat then
      room:useVirtualCard("slash", nil, player, user, zhengshuo.name)
    end
  end
}, { check_skill_limit = true })

Fk:loadTranslationTable{
  ["th_zhengshuo"] = "正朔",
  [":th_zhengshuo"] = "每回合限一次，你对其他角色造成伤害后，你可以令你攻击范围内的一名角色选择一项：1.将一张手牌当【杀】对受伤角色使用；2.视为你对其使用一张【杀】。",

  ["#th_zhengshuo-invoke"] = "正朔：你可以令你攻击范围内的一名角色选择一项：将一张手牌当【杀】对 %dest 使用，否则视为你对其使用【杀】",
  ["#th_zhengshuo-slash"] = "正朔：你须将一张手牌当【杀】对 %dest 使用，否则视为 %src 对你使用【杀】",
}

return zhengshuo